<template>
    <div>
        <div style="display:none">
            <div id='hour'></div>
            <div id='year'></div>
        </div>
        <cjc-nav title="确认用户信息" @customRouter="customRouter"></cjc-nav>
        <div class="content">
            <div class="message">
                <p>您正在使用自助终端进行打印服务</p>
                <p>是否继续？</p>
            </div>
            <div>
                <Button type="primary" long size="large" @click="loading">确认</Button>
            </div>
            <div class="cancl">
                <Button type="ghost" long size="large" @click="cancel">取消</Button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'home',
    created() {
        const self = this
        this.$store.dispatch('login', {
            Vm: this,
            username: '1711102012',
            password: '416321',
            type: 1
        }).then(res => {
            console.log('res', res)
            self.TempUserInfo = res.result
            console.log('login info', self.TempUserInfo)
            // USER_ID
        })
    },
    data() {
        return {
            TempUserInfo: ''
        }
    },
    methods: {
        customRouter() {
            // ll
        },
        loading() {
            // 获取浏览器传的参数 截取clientId用于保存浏览器标识
            let url = window.location.href
            // document.write(url)
            let urldata = decodeURIComponent(url)
            urldata = urldata.substring(urldata.indexOf('data') + 5, urldata.length + 1)
            // alert(urldata)
            let clientInfo = JSON.parse(urldata)
            console.log('clientInfo', clientInfo)
            const msg = this.$Message.loading({
                top: 200,
                content: '正在确认中',
                duration: 0
            })
            let userLoginInfo = {
                interface: 'userLogin',
                clientId: clientInfo.clientId,
                userInfo: this.TempUserInfo
            }
            console.log('userLoginInfo', userLoginInfo)
            this.socket.sendMessage(userLoginInfo)
            setTimeout(msg, 3000)
            // this.$cjc.closeWebView()
        },
        cancel() {
            this.$cjc.closeWebView()
            // this.$router.push({
            //     path: '/mobilePay'
            // })
        },
        getQueryString(name) {
            let reg = `(^|&)${name}=([^&]*)(&|$)`
            let r = window.location.search.substr(1).match(reg)
            if (r != null) return unescape(r[2]); return null
        }
    },
    components: {
        // cjcNav: () => import('@/components/common/Nav.vue'),
    }
}
</script>

<style lang="less">
.content {
    width: 80%;
    height: 321px;
    text-align: center;
    margin: 52% 10%;
    font-weight: 550;
}
.message {
    width: 95%;
    font-size: 18px;
    margin-left: 2.5%;
    padding-bottom: 22%
}
.cancl {
    padding-top: 4%;
}
.cancl .ivu-btn-Ghost {
    background-color:#e1e1e1;
}
.ivu-message {
    top:316px;
}
</style>
